package com.example.webSocketTest.controller;

import com.example.webSocketTest.socket.WebSocketServer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("send")
public class WebSocketController {
    @GetMapping("{message}/{sid}")
    public String socketController1(@PathVariable("message")String message,
                                   @PathVariable("sid")String sid) throws IOException {
        WebSocketServer.sendMessageToClient(message,sid);
        return "success111";
    }

    @GetMapping("{message}")
    public String socketController2(@PathVariable("message")String message) throws IOException {
        WebSocketServer.sendMessageToAll(message);
        return "success222";
    }
}
